#  NETMAJ - network mahjongg -  Copyright Notice
#      Copyright (C) 1994, 1995, 1996 Koji Suzuki (suz@kt.rim.or.jp)
# 
#   You can redistribute it and/or modify this software under the terms 
#  of the GNU General Public License version 2 as published by
#  the Free Software Foundation.
# 
#   This software is provided 'as-is', without any express or implied
#  warranty.  In no event will the author be held liable for any damages
#  arising from the use of this software.
#  See the gpl.text for more details.
# 
#   If you would like to do something with NETMAJ that this copyright
#  prohibits (such as distributing it with a commercial product,
#  using portions of the source in some other program, etc.), please
#  contact the author (preferably via email).  Arrangements can
#  probably be worked out.
# 
#   Koji Suzuki   : suz@kt.rim.or.jp
#
# $Id: Makefile,v 1.3 1996/09/05 10:30:12 suz Exp $

SHELL=/bin/sh
# Install Directory
LIBDIR=/usr/local/lib/netmaj
BINDIR=/usr/local/bin
PERL=/usr/bin/perl

STD_CFLAGS=-I.. -I../lib -DNETMAJ_LIB=\"$(LIBDIR)\" -DINTEST

# for 386BSD,FreeBSD,NetBSD...
CC=gcc
OS_CFLAGS= -O -g -DUSE_SGTTY -DUSE_FWOPEN -DUSE_TERMCAP -DHAVE_GETTIMEOFDAY
RANLIB=ranlib
LIBS= 
CURSES= -lcurses -ltermcap
LDFLAGS =  -L../lib 

# for linux
#CC=cc
#OS_CFLAGS= -O -DUSE_TERMIOS -DUSE_TERMCAP -DDEF_OPTARG -DHAVE_GETTIMEOFDAY
#RANLIB=ranlib
#LIBS = 
#CURSES= lib/libcurses.a -ltermcap
#LDFLAGS =  -Llib 

# for nec ews
##CC=/usr/abiccs/bin/cc -ZXNd=5000
#CC=gcc -ansi
#OS_CFLAGS = -O -DSYSV -DSVR4 -DUSE_TERMIOS -DUSE_TERMINFO \
#	-D_ENDWIN_INCURSES  -DHAVE_GETTIMEOFDAY -DDEF_OPTARG
#RANLIB=echo
#LIBS = -lsocket -lnsl
#CURSES= -lcurses -ltermcap
#LDFLAGS =  -Llib 

# for Solaris
#CC=cc
#OS_CFLAGS = -O -DSYSV -DSVR4 -DUSE_TERMIOS -DUSE_TERMINFO -D_ENDWIN_INCURSES \
#	-DUSE_RAND  -DHAVE_GETTIMEOFDAY
#RANLIB=echo
#LIBS = -lsocket -lnsl
#CURSES= -lcurses -ltermcap
#LDFLAGS =  -Llib 

# for nec ews (SVR2)
#CC=cc
#OS_CFLAGS = -O -DSYSV -DSVR4 -DUSE_TERMIO \
#	-DNO_U_LONG -DUSE_TERMCAP -DDEF_OPTARG -DNO_STDLIB -DUSE_WAIT3
#RANLIB=echo
#LIBS =  
#CURSES= -lcurses -ltermcap
#LDFLAGS =  -Llib 

# for SunOS 4.x
#CC=cc 
#OS_CFLAGS= -O -DDEF_OPTARG -DUSE_SGTTY -DUSE_TERMCAP  -DHAVE_GETTIMEOFDAY \
#	-DUSE_WAIT3
#RANLIB=ranlib
#LIBS= -Llib 
#CURSES= -lcurses -ltermcap
#LDFLAGS =

# for HP-UX 9.x
#CC=cc 
#OS_CFLAGS= -O -DSYSV -DUSE_TERMIOS -DUSE_TERMINFO  -DHAVE_GETTIMEOFDAY \
#	-DUSE_WAIT3
#RANLIB=echo
#LIBS= 
#CURSES= -lcurses -ltermcap
#LDFLAGS =  -Llib

# for AIX 3.x
#CC=cc 
#OS_CFLAGS= -O -DSYSV -DOLD_SELECT -DUSE_TERMIOS -DUSE_TERMCAP  \
#	-DHAVE_GETTIMEOFDAY -DUSE_WAIT3
#RANLIB=echo
#LIBS= 
#CURSES= -lcurses -ltermcap
#LDFLAGS =  -Llib

CFLAGS=$(STD_CFLAGS) $(OS_CFLAGS)

OBJS_LIB= analize2.o 
OBJS_SERVER=../server.o
OBJS_CLIENT=../client.o ../cui.o 
OBJS_AUTO  =../auto.o 
OBJS_STAND  = xstand.o 
OBJS_PLVIEW  = ../plview.o ../cui.o 
OBJS_NETMAJ1 =../netmaj1.o ../cui.o 

all: xstand auto client netmaj1 x

libnetmaj.a: ../libnetmaj.a $(OBJS_LIB)
	cp ../libnetmaj.a .
	ar ruc libnetmaj.a $(OBJS_LIB)
	$(RANLIB) libnetmaj.a

server: $(OBJS_SERVER) libnetmaj.a
	$(CC) -o server $(OBJS_SERVER) libnetmaj.a $(LDFLAGS) $(LIBS)

xstand: $(OBJS_STAND) libnetmaj.a
	$(CC) -o xstand $(OBJS_STAND) libnetmaj.a $(LDFLAGS) 

netmaj1: $(OBJS_NETMAJ1) libnetmaj.a $(OBJS_COMMON) 
	$(CC) -o netmaj1 $(OBJS_NETMAJ1) libnetmaj.a $(OBJS_COMMON) $(LDFLAGS) \
	 $(LIBS) $(CURSES) 

auto: $(OBJS_AUTO) libnetmaj.a
	$(CC) -o auto $(OBJS_AUTO) libnetmaj.a $(LDFLAGS) $(LIBS)

client: $(OBJS_CLIENT) libnetmaj.a
	$(CC) -o client $(OBJS_CLIENT) libnetmaj.a $(LDFLAGS) $(LIBS) $(CURSES) 

x:
	-if test -d xui; then \
	(cd xui; make CC="$(CC)" OS_CFLAGS="$(OS_CFLAGS)" \
	RANLIB="$(RANLIB)" LIBS="$(LIBS)" LIBDIR="$(LIBDIR) \
	BINDIR="$(BINDIR)" \
	"); fi

install: netmaj player_info
	-if test ! -d ${BINDIR}; then \
		mkdir ${BINDIR}; fi
	-if test ! -d ${LIBDIR}; then \
		mkdir ${LIBDIR}; fi
	-./server_kill
	cp server client auto server_kill player_info $(LIBDIR)
	cp proxyserver inputserver proxyclient $(LIBDIR)
	cp netmaj.hlp $(LIBDIR)
	cp netmaj netmaj1 plview $(BINDIR)
	-if test -d xui; then \
	(cd xui; make install CC="$(CC)" OS_CFLAGS="$(OS_CFLAGS)" \
	RANLIB="$(RANLIB)" LIBS="$(LIBS)" LIBDIR="$(LIBDIR)" \
	BINDIR="$(BINDIR)" \
	); fi

install-remote: netmaj server server_kill auto proxyclient
	-if test ! -d ${BINDIR}; then \
		mkdir ${BINDIR}; fi
	-if test ! -d ${LIBDIR}; then \
		mkdir ${LIBDIR}; fi
	cp server auto server_kill proxyclient $(LIBDIR)
	cp netmaj $(BINDIR)

clean:
	rm -f *.o core* a.out server auto client server_kill \
		netmaj player_info libnetmaj.a
	(cd lib; make clean)
	-if test -d xui; then \
	(cd xui; make clean); fi

analize2.o : analize2.c ../pai.h ../ahand.h ../global.h 
xstand.o : xstand.c ../pai.h ../ahand.h ../global.h 

